(*INSTRUCTIONS: First,open the Drawing Tools palette from the Graphics menu:

			In the Drawing Tools palette choose the Get Coordinates tool:

			Hover over the graph below and the coordinates of the point under the cursor are displayed next to the cursor. Click to mark the point you wish to use as data in the graphic for later copying. Similarly dragging marks a set of points along the path:*)

Show[ListPlot[{0,0}],PlotRange->{{0,11},{0,6}}]

(*INSTRUCTIONS: After clicking or dragging points,use Edit ► Copy to put the coordinates of the points on the clipboard then use Edit ► Paste to paste them below.*)

XY = (*Paste IMMEDIATELY BELOW*)

(*Hold "Shift" and press "Enter".*)

(*Click anywhere below, hold "Shift" and press "Enter".*)

Print["XY = ", XY];

p2[x_] = Fit[XY,{1,x,x^2},x];
f[x_] = p2[x];
Print["The polynomial of best fit degree 2 = y = (Subscript[p, 2])[x] =", p2[x]];
Print["The RMS value of the function y is: ",RootMeanSquare[XY[[All,2]]-Map[p2,XY[[All,1]]]]];
Print["The roots of the function y are:", data2D];
Show[Plot[p2[x],{x,-20,20},PlotRange->{{0,11},{0,6}}],ListPlot[XY]]
<<ComputationalGeometry`
data2D = {{Re[Root[p2[x],1]],Im[Root[p2[x],1]]},{Re[Root[p2[x],2]],Im[Root[p2[x],2]]}};
VoronoiDiagram[data2D,delval];
Show[DiagramPlot[data2D,LabelPoints->False],ListPlot[data2D],PlotRange->{{-10,15},{-10,10}}]

p3[x_] = Fit[XY,{1,x,x^2,x^3},x];
f[x_] = p3[x];
Print["The polynomial of best fit degree 3 = y = (Subscript[p, 3])[x] =", p3[x]];
Print["The RMS value of the function y is: ",RootMeanSquare[XY[[All,2]]-Map[p3,XY[[All,1]]]]];
Print["The roots of the function y are:", data3D];
Print["The area of the convex hull is: ",ConvexHullArea[data3D]];
Show[Plot[p3[x],{x,-20,20},PlotRange->{{0,11},{0,6}}],ListPlot[XY]]
<<ComputationalGeometry`
data3D = {{Re[Root[p3[x],1]],Im[Root[p3[x],1]]},{Re[Root[p3[x],2]],Im[Root[p3[x],2]]},{Re[Root[p3[x],3]],Im[Root[p3[x],3]]}};
VoronoiDiagram[data3D,delval];
Show[DiagramPlot[data3D,LabelPoints->False],ListPlot[data3D],PlotRange->{{-10,15},{-10,10}}]
convexhull=ConvexHull[data3D];
Show[PlanarGraphPlot[data3D,convexhull,LabelPoints->False],PlotRange->{{-10,15},{-10,10}}]

p4[x_] = Fit[XY,{1,x,x^2,x^3,x^4},x];
f[x_] = p4[x];
Print["The polynomial of best fit degree 4 = y = (Subscript[p, 4])[x] =", p4[x]];
Print["The RMS value of the function y is: ",RootMeanSquare[XY[[All,2]]-Map[p4,XY[[All,1]]]]];
Print["The roots of the function y are:", data4D];
Print["The area of the convex hull is: ",ConvexHullArea[data4D]];
Show[Plot[p4[x],{x,-20,20},PlotRange->{{0,11},{0,6}}],ListPlot[XY]]
<<ComputationalGeometry`
data4D = {{Re[Root[p4[x],1]],Im[Root[p4[x],1]]},{Re[Root[p4[x],2]],Im[Root[p4[x],2]]},{Re[Root[p4[x],3]],Im[Root[p4[x],3]]},{Re[Root[p4[x],4]],Im[Root[p4[x],4]]}};
VoronoiDiagram[data4D,delval];
convexhull=ConvexHull[data4D];
Show[DiagramPlot[data4D,LabelPoints->False],ListPlot[data4D],PlotRange->{{-10,15},{-10,10}}]
Show[PlanarGraphPlot[data4D,convexhull,LabelPoints->False],PlotRange->{{-10,15},{-10,10}}]


p5[x_] = Fit[XY,{1,x,x^2,x^3,x^4,x^5},x];
f[x_] = p5[x];
Print["The polynomial of best fit degree 5 = y = (Subscript[p, 5])[x] =", p5[x]];
Print["The RMS value of the function y is: ",RootMeanSquare[XY[[All,2]]-Map[p5,XY[[All,1]]]]];
Print["The roots of the function y are:", data5D];
Print["The area of the convex hull is: ",ConvexHullArea[data5D]];
Show[Plot[p5[x],{x,-20,20},PlotRange->{{0,11},{0,6}}],ListPlot[XY]]
<<ComputationalGeometry`
data5D = {{Re[Root[p5[x],1]],Im[Root[p5[x],1]]},{Re[Root[p5[x],2]],Im[Root[p5[x],2]]},{Re[Root[p5[x],3]],Im[Root[p5[x],3]]},{Re[Root[p5[x],4]],Im[Root[p5[x],4]]},{Re[Root[p5[x],5]],Im[Root[p5[x],5]]}};
VoronoiDiagram[data5D,delval];
Show[DiagramPlot[data5D,LabelPoints->False],ListPlot[data5D],PlotRange->{{-10,15},{-10,10}}]
convexhull=ConvexHull[data5D];
Show[PlanarGraphPlot[data5D,convexhull,LabelPoints->False],PlotRange->{{-10,15},{-10,10}}]

p6[x_] = Fit[XY,{1,x,x^2,x^3,x^4,x^5,x^6},x];
f[x_] = p6[x];
Print["The polynomial of best fit degree 6 = y = (Subscript[p, 6])[x] =", p6[x]];
Print["The RMS value of the function y is: ",RootMeanSquare[XY[[All,2]]-Map[p6,XY[[All,1]]]]];
Print["The roots of the function y are:", data6D];
Print["The area of the convex hull is: ",ConvexHullArea[data6D]];
Show[Plot[p6[x],{x,-20,20},PlotRange->{{0,11},{0,6}}],ListPlot[XY]]
<<ComputationalGeometry`
data6D = {{Re[Root[p6[x],1]],Im[Root[p6[x],1]]},{Re[Root[p6[x],2]],Im[Root[p6[x],2]]},{Re[Root[p6[x],3]],Im[Root[p6[x],3]]},{Re[Root[p6[x],4]],Im[Root[p6[x],4]]},{Re[Root[p6[x],5]],Im[Root[p6[x],5]]},{Re[Root[p6[x],6]],Im[Root[p6[x],6]]}};
VoronoiDiagram[data6D,delval];
Show[DiagramPlot[data6D,LabelPoints->False],ListPlot[data6D],PlotRange->{{-10,15},{-10,10}}]
convexhull=ConvexHull[data6D];
Show[PlanarGraphPlot[data6D,convexhull,LabelPoints->False],PlotRange->{{-10,15},{-10,10}}]

p7[x_] = Fit[XY,{1,x,x^2,x^3,x^4,x^5,x^6,x^7},x];
f[x_] = p7[x];
Print["The polynomial of best fit degree 7 = y = (Subscript[p, 7])[x] =", p7[x]];
Print["The RMS value of the function y is: ",RootMeanSquare[XY[[All,2]]-Map[p7,XY[[All,1]]]]];
Print["The roots of the function y are:", data7D];
Print["The area of the convex hull is: ",ConvexHullArea[data7D]];
Show[Plot[p7[x],{x,-20,20},PlotRange->{{0,11},{0,6}}],ListPlot[XY]]
<<ComputationalGeometry`
data7D = {{Re[Root[p7[x],1]],Im[Root[p7[x],1]]},{Re[Root[p7[x],2]],Im[Root[p7[x],2]]},{Re[Root[p7[x],3]],Im[Root[p7[x],3]]},{Re[Root[p7[x],4]],Im[Root[p7[x],4]]},{Re[Root[p7[x],5]],Im[Root[p7[x],5]]},{Re[Root[p7[x],6]],Im[Root[p7[x],6]]},{Re[Root[p7[x],7]],Im[Root[p7[x],7]]}};
VoronoiDiagram[data7D,delval];
Show[DiagramPlot[data7D,LabelPoints->False],ListPlot[data7D],PlotRange->{{-10,15},{-10,10}}]
convexhull=ConvexHull[data7D];
Show[PlanarGraphPlot[data7D,convexhull,LabelPoints->False],PlotRange->{{-10,15},{-10,10}}]

p8[x_] = Fit[XY,{1,x,x^2,x^3,x^4,x^5,x^6,x^7,x^8},x];
f[x_] = p8[x];
Print["The polynomial of best fit degree 8 = y = (Subscript[p, 8])[x] =", p8[x]];
Print["The RMS value of the function y is: ",RootMeanSquare[XY[[All,2]]-Map[p8,XY[[All,1]]]]];
Print["The roots of the function y are:", data8D];
Print["The area of the convex hull is: ",ConvexHullArea[data8D]];
Show[Plot[p8[x],{x,-20,20},PlotRange->{{0,11},{0,6}}],ListPlot[XY]]
<<ComputationalGeometry`
data8D = {{Re[Root[p8[x],1]],Im[Root[p8[x],1]]},{Re[Root[p8[x],2]],Im[Root[p8[x],2]]},{Re[Root[p8[x],3]],Im[Root[p8[x],3]]},{Re[Root[p8[x],4]],Im[Root[p8[x],4]]},{Re[Root[p8[x],5]],Im[Root[p8[x],5]]},{Re[Root[p8[x],6]],Im[Root[p8[x],6]]},{Re[Root[p8[x],7]],Im[Root[p8[x],7]]},{Re[Root[p8[x],8]],Im[Root[p8[x],8]]}};
VoronoiDiagram[data8D,delval];
Show[DiagramPlot[data8D,LabelPoints->False],ListPlot[data8D],PlotRange->{{-10,15},{-10,10}}]
convexhull=ConvexHull[data8D];
Show[PlanarGraphPlot[data8D,convexhull,LabelPoints->False],PlotRange->{{-10,15},{-10,10}}]